package org.csu.backofficemanagersys.interceptor;


//这是将前端的传入的密码进行base64加密的拦截器，但是在设想中，前端传入的已经是base64加密的密码，所以这个类先弃之不用

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.csu.backofficemanagersys.base64.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * 可以考虑写成一个base64的解密类，这样在前端就可以看到明文密码
 */
@Component
public class Base64Interceptor implements HandlerInterceptor {
    @Autowired
    Base64 base64;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        return true;
        //默认值为false，代表不继续往后执行。如果为true，即使拦截了也依然会执行被拦截请求对应的controller层对应的方法。因此为true和没加拦截没区别
        //为false的话，被拦截的请求不会被执行它对应的controller方法
    }
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }

}
